package cc.aiee.alipay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

import cn.hutool.core.util.StrUtil;

public class AliPayConfigKit {

	private static final String GETWAY = "https://openapi.alipay.com/gateway.do";

	public static AlipayClient getAlipayClient(AliPayConfig config) {
		String charset = "UTF-8";
		if (StrUtil.isBlank(config.getCharset())) {
			config.setCharset(charset);
		}
		AlipayClient alipayClient = new DefaultAlipayClient(GETWAY, config.getAppId(), config.getAppPrivateKey(),
				"json", config.getCharset(), config.getAlipayPublicKey(), "RSA2");
		return alipayClient;
	}
}
